package com.xiaoshuidi.cloud.module.member.controller.app.activities;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.module.member.controller.app.activities.vo.EnrollListVO;
import com.xiaoshuidi.cloud.module.member.controller.app.activities.vo.EnrollStatusPageVO;
import com.xiaoshuidi.cloud.module.member.controller.app.activities.vo.EnrollVO;
import com.xiaoshuidi.cloud.module.member.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.member.service.activities.MemberActivitiesEnrollService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.success;

@Tag(name = "租客APP - 活动")
@RestController
@RequestMapping(ApiConstants.NAME+"/activity-enroll")
@Validated
public class AppMemberActivityEnrollController {
    @Resource
    private MemberActivitiesEnrollService memberActivitiesEnrollService;

    @GetMapping("/enroll-or-not/{activityId}")
    @Operation(summary = "是否可以报名")
    public CommonResult<Boolean> enrollOrNot(@PathVariable("activityId") Long activityId) {
        return success(memberActivitiesEnrollService.enrollOrNot(activityId));
    }

    @PostMapping("/enroll")
    @Operation(summary = "活动报名")
    public CommonResult<Boolean> enroll(@RequestBody EnrollVO vo) {
        return success(memberActivitiesEnrollService.enroll(vo));
    }

    @PostMapping("/get-status-page")
    @Operation(summary = "获取状态分页列表")
    public CommonResult<PageResult<EnrollListVO>> getStatusPage(@RequestBody EnrollStatusPageVO page) {
        return success(memberActivitiesEnrollService.getStatusPage(page));
    }



}
